/**
 * 
 */
package model.staff;

import java.sql.ResultSet;
import java.util.ArrayList;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import myutil.Connect;

import vo.mixed.LibraryProfessorVo;
//import vo.mixed.LibraryStudentVo;

/**
 * @author Pooja 
 *
 */
public class LibraryMo {
	ArrayList<LibraryProfessorVo> list=new ArrayList<LibraryProfessorVo>();
	public ArrayList<LibraryProfessorVo> getIssuedBooks() {
		
		HttpSession session;
		session = ServletActionContext.getRequest().getSession();
		int id=(int) session.getAttribute("user_id");
		String query="select sbb.book_id,borrower_id,issue_date,return_date,fine,price,category,book_name,author_name,returned from staff_book_borrow sbb,library_book_details sbd where sbb.book_id=sbd.book_id and borrower_id="+id;
		System.out.println(query);
		Connect c=new Connect();
		try {
			ResultSet rs=c.getResult(query);
			while(rs.next())
			{
				LibraryProfessorVo vo=new LibraryProfessorVo();
				vo.setBook_id(rs.getInt("book_id"));
				vo.setAuthor_name(rs.getString("author_name"));
				vo.setBook_name(rs.getString("book_name"));
				vo.setCategory(rs.getString("category"));
				vo.setPrice(rs.getInt("price"));
				vo.setBorrower_id(rs.getInt("borrower_id"));
				vo.setIssue_date(rs.getString("issue_date"));
				vo.setReturn_date(rs.getString("return_date"));
				vo.setFine(rs.getInt("fine"));
				vo.setStaff_id(rs.getInt("borrower_id"));
				vo.setReturned(rs.getInt("returned"));
				list.add(vo);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}

}
